# 定义非空字典
# info = {
#     "name": "河南小伙",
#     "age": 18,
#     "gender": "男",
#     "hobby": {"read": "小说", "sport": ["篮球", "足球"]}
# }
# # 查询年龄
# print(info["age"])
# print(info.get("age"))
# # 查询键aa的值
# print(info.get("aa")) # None 表示aa键不存在
# print(info["hobby"]["sport"][1])
# print(info.get("hobby").get("sport")[1])

#字典合并/新增
# # 定义字典1
# dict1 = {"name": "河南小伙", "age": 18}
# # 定义字典2
# dict2 = {"height": 1.88}
# # 将字典2合并到字典1
# dict1.update(dict2)
# print(dict1)

#字典的遍历
# 定义非空字典
# info = {
#     "name": "河南小伙",
#     "age": 18,
#     "gender": "男"
# }
# # 遍历获取字典中所有键
# for i in info.keys():
#     print(f"字典的键是：{i}")
# # 遍历获取字典中所有值
# for i in info.values():
#     print(f"字典的值是：{i}")
# # 遍历获取字典的键和值
# for k, v in info.items():
#     print(f"{k} = {v}")

#2.5集合
# 定义空集合
# info = set()
# print(info)
# # 集合中添加元素："a"
# info.add("a")
# info.add("b")
# print(info)
# # 定义非空字符串
# var = "abcdeabdcdf"
# # 打印非重复的元素
# print(set(var)) # 转换为集合去重 # {'c', 'f', 'e', 'a', 'b', 'd'}
# tmp = list(set(var)) # 再转换为列表
# tmp.sort() # 再进行排序
# print(tmp) # ['a', 'b', 'c', 'd', 'e', 'f']
# print("".join(tmp))

# #序列长度
# # 定义非空字符串
# info = "abcdefgh"
# info1 = "Hello Python"
# # 统计字符元素个数（长度）
# print(len(info))
# print(len(info1))
# # 定义非空列表
# info2 = [11, "aa", 1.88, (1, 2, 3), ["aa", "bb"]]
# print(len(info2))
# # 定义非空元组
# info3 = (11, "aa", 1.88)
# print(len(info3))
# # 定义非空字典
# info4 = {"name": "tom", "age": 18, "gender": "男"}
# print(len(info4))

# #清空序列
# info2 = [11, "aa", 1.88, (1, 2, 3), ["aa", "bb"]]
# # 清空列表数据
# info2.clear()
# # 查看原有列表
# print(info2)
# info4 = {"name": "tom", "age": 18, "gender": "男"}
# # 清空字典数据
# info4.clear()
# # 查看原有字典
# print(info4)